package xzr2;

import java.util.Scanner;

public class WormPare {
    private static Worm worm;
    private int rows=15;
    private int cols=30;
    public WormPare(){
        worm=new Worm();
    }
    public void print(){
        for(int i=0;i<rows;i++){
            for(int j=0;j<cols;j++){
                if(i==0||i==rows-1){
                    System.out.print("-");
                }else if(j==0||j==cols-1){
                    System.out.print("|");
                }else if(worm.baohan(i, j)){
                    System.out.print("#");
                }
                else{
                    System.out.print(" ");
                }
            }System.out.println();
        }
    }
    public static void main(String[] args) {
        WormPare pan=new WormPare();
        Scanner aa=new Scanner(System.in);

        while(true){
            pan.print();
            String cmd=aa.nextLine();

            if(cmd.equals("u")){
                worm.step(Worm.up);
            }else if(cmd.equals("d")){
                worm.step(Worm.down);

            }else if(cmd.equals("r")){
                worm.step(Worm.right);

            }else if(cmd.equals("l")){
                worm.step(Worm.left);
            }
        }
    }
}
